package com.jiazhong.mingxing.project.bookstore.front.controller;

import com.jiazhong.mingxing.project.bookstore.commons.bean.Address;
import com.jiazhong.mingxing.project.bookstore.commons.util.JsonResult;
import com.jiazhong.mingxing.project.bookstore.front.service.AddressService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Resource
    private AddressService addressService;

    @GetMapping
    public JsonResult find(HttpServletRequest request) {
        return addressService.findAddressByUserId(request);
    }

    @PostMapping("/save")
    public JsonResult save(Address address, HttpServletRequest request) {
        return addressService.saveAddress(address, request);
    }
}
